import 'dart:async';
import 'package:containerbox_study/routers/router_table.dart';
import 'package:flutter/material.dart';

class SplashPage extends StatefulWidget{
  @override
  State<StatefulWidget> createState() => _SplashState();
}

class _SplashState extends State<SplashPage>{
  bool _initialized = false;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(      
        child: Container(
        width: 120,
        height: 120,
        decoration: BoxDecoration(
          borderRadius: BorderRadius.all(Radius.circular(60)),
        ),
        child: Image.asset('images/logo.png', fit: BoxFit.fill,),
      ),
),
    );
  }

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    if (!_initialized){
      _initialized = true;
      Timer(Duration(milliseconds: 2000), (){
        RouterManager.router!.navigateTo(context, RouterManager.homePath,clearStack: true);
        // Navigator.of(context).pushReplacementNamed(RouterTable.homePath);
      });
    }
  }
}